package application.controller.server;
import java.util.Properties;

import javax.*;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.QueueConnectionFactory;
import javax.jms.Session;
import javax.naming.InitialContext;
import javax.naming.NamingException;


public class MessageController extends AbstractUseCaseController {
	
	public MessageController(){
		
	}

	public static void main(String[] args) throws NamingException, JMSException{
		InitialContext ctx = new InitialContext();
		ConnectionFactory cf = (QueueConnectionFactory) ctx.lookup("LibConnectionFactory");
		Destination dest = (Destination) ctx
				.lookup("Lib");
		Connection con = cf.createConnection();
		Session sess = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
		MessageProducer prod = sess.createProducer(dest);
		Message msg = sess.createTextMessage("Hello");
		prod.send(msg);
		con.close();
		System.out.println("Connection closed");
		
	}

}
